<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>友情链接新增</title>
<link rel="stylesheet" href="${base}/images/contentImage/main.css" />
<link rel="stylesheet" type="text/css" href="${base}/js/uploadify/uploadify.css"/>
<link rel="stylesheet" href="${base}/css/validationEngine.jquery.css" type="text/css"/>

<script type="text/javascript" src="${base}/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="${base}/js/ajaxupload.js"></script>
<script type="text/javascript" src="${base}/js/jquery.validationEngine.js"></script>
<script type="text/javascript" src="${base}/js/jquery.validationEngine-zh_CN.js"></script>
<script type="text/javascript" src="${base}/js/jquery.blockUI.js"></script>
<script type="text/javascript" src="${base}/js/My97DatePicker4_8/WdatePicker.js"></script>
<script type="text/javascript" src="${base}/js/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript" src="${base}/js/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript">
	function saveLink(){
		var form1 = $("#tableForm");
		
		form1.submit();
	}
	function myAlert(txt){
		window.parent.$.dialog({
			lock: true,
			content: txt,
			cancelVal: '确定',
			autoSize:true,
		    cancel: function(){ //请求成功后处理函数。 
			}
		});
	}
	$(document).ready(function(){
		var msg = $("#msg").val();
		if(msg=="success"){
			$.dialog.alert("保存成功");
		} else if (msg == 'failed'){
			$.dialog.alert("保存失败");
		}
		$("#tableForm").validationEngine({
			promptPosition: "topLeft",
			onValidationComplete: function(form, status){
	        	if (status == true) {                   
	            	form.validationEngine('detach');
	            	form.submit();
	       	 	} else {
	       	 		$.unblockUI();
				}
			}       
		});
	});
	
	function showImg(e){
		var ele = document.getElementById("linkImg");
		ele.style.display = '';
		/* ele.width = 200;
		ele.height = 200; */
		ele.src = e.value;
		/* var width = ele.width - 0;
		var height = ele.height - 0;
		var max = width > height ? width : height;
		max = max ? max : 200;
		var rate = max > 200 ? (200/max) : 1;
		ele.width = width * rate
		ele.height = height * rate; */
	}

</script>
</head>

<body>
<input type="hidden" id="msg" name="msg" value="${msg!}"/>
<form action="${base!}/link/admin/saveLink.htm" method="post" id="tableForm" name="tableForm" enctype="multipart/form-data">	
	<table width="98%" border="0" cellspacing="1" cellpadding="2" class="border-t" style="border-left: 1px solid #bed3df; border-right: 1px solid #bed3df; margin: 0px auto;">
		<tbody>
			<tr>
				<td class="itemtit">链接名:</td>
				<td class="border_b">
					<input class="w150 validate[required]" type="text" name="linkName" value="${link.linkName}" />
				</td>
			</tr>
			<tr>
				<td class="itemtit">链接地址:</td>
				<td class="border_b">
					<input class="w150 validate[required]" type="text" name="linkUrl" value="${link.linkUrl}" />
				</td>
			</tr>
			<tr>
				<td class="itemtit">链接类型:</td>
				<td class="border_b">
					<select name="linkType">
						<option value="1" <#if link.linkType==1>selected</#if>>页面下方友情链接</option>
						<option value="2" <#if link.linkType==2>selected</#if>>QQ咨询链接</option>
					</select>
				</td>
			</tr>
			<tr>
				<td class="itemtit" rowspan="2">链接图片:</td>
				<td>
					<input type="file" onchange="showImg(this)" name="linkImg"/>
				</td>
			</tr>
			<tr>
				<td>
					<img src="" alt="" id="linkImg"  width="200" height="200" style="display: none;"/>
				</td>
			</tr>
		</tbody>
	</table>
	</form>
</body>
</html>